<?
layout("/inc/layout.html",{title:sysTitle}){
?>

<div id="page-wrapper">
	<!--BEGIN TITLE & BREADCRUMB PAGE-->
	<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
		<div class="page-header pull-left">
			<div class="page-title">专题权限配置</div>
		</div>
		<ol class="breadcrumb page-breadcrumb pull-left">
			<li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i
				class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li>大数据分析专题&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li class="active">专题权限配置</li>
		</ol>

		<div class="clearfix"></div>
	</div>
	<!--END TITLE & BREADCRUMB PAGE-->
	<!--BEGIN CONTENT-->
	<div class="page-content">

		<div class="row mbl">
			<div class="col-lg-12">
				<div class="input-group input-group-sm mbs" style="width:100%;">
					<table style="margin-top: 5px;width:100%;">
						<tr >
							<td align="right" style="width: 100px;">用户类型&nbsp;&nbsp;</td>
							<td>
								<select id="type" class="form-control" tyle="width: 100%;">
									<option value="">请选择</option>
									<option value="1">机构</option>
									<option value="0">个人</option>
								</select>
							</td>
							<td align="right" style="width: 80px;">用户名&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 100%;" id="username" name="username" /></td>
							<td align="right" style="width: 100px;">用户名称&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 100%;" id="realname" name="realname" /></td>
							<td align="right" style="width: 100px;">
								<button type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="demo(1)">查询</button>
								&nbsp;&nbsp;
							</td>
							<td align="center" style="width: 100px;">
								<button class="btn btn-primary" onclick="addUpdateJurisdiction('0')">新增</button>
								&nbsp;&nbsp;
							</td>
						</tr>
					</table>
				</div>
			</div>
		</div>
		<table
			class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
			<thead>
				<tr>
					<th>序号</th>
					<th>用户名称</th>
					<th>用户名</th>
					<th>用户类型</th>
					<th>专题名称</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody id="findMemeber">
			</tbody>
		</table>
		
		<div id="dataNull" class="panel-body"
			style="height: 90px; line-height: 50px;" align="center"></div>
		<!-- <div id="page2" style="text-align: center; margin-top: 20px;"></div> -->
	</div>

	<!--END CONTENT-->
</div>


<?} ?>
<script>
	var curr;
	$(function() {
		demo(1);
	});
	
	function get() {
		demo(curr);
	}
	function getlay() {
		return id;
	}
	//新增
	function addUpdateJurisdiction(lid) {
		id = lid;
		jurisdictionTitle = "";
		if(lid == 0){
			jurisdictionTitle = "专题权限配置添加";
		}else{
			jurisdictionTitle = "专题权限配置编辑";
		}
		layer.open({
			type : 2,
			area : [ '450px', '450px' ],
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,
			title : jurisdictionTitle,
			//maxmin : true,  
			move : true,
			skin : 'layui-layer-rim', //加上边框
			btn : [ '保存 ', '关闭' ],
			content : [ "analysis-jurisdiction-configuration-add-update.html", 'no' ],
			yes : function(index, layer) {
				var iframeWin = parent.window[layer.find('iframe')[0]['name']];
				iframeWin.save();
			},
			cancel : function(index) {
			}

		});
	}
	
	//默认加载
	function demo(curr) {
		$.getJSON(
			"queryJurisdictionAll.do",
			{
				page : curr || 1,
				username : $("#username").val(),
				realname : $("#realname").val(),
				type : $("#type").val()
			},
		function(res) {
			//alert(JSON.stringify(res));
			var str = "";
			
			/*  if (res.length > 1) {
				$("#dataNull").html("");
			} else {
				$("#dataNull").html(
					"<span class='subtitle' style='font-size: 15px;'>数据为空!</span>");
			}  */
			
			if(res[0].msg == "OK"){
				$("#findMemeber").html("");
				for ( var i = 0; i < res[0].data.length; i++) {
					str += "<tr><td>"
						+ (i + 1)
						+ "</td><td> <label id=>"
						+ res[0].data[i].realName
						+ "</label></td><td><label >"
						+ res[0].data[i].username
						+ "</label></td><td><label >"
						+ res[0].data[i].sType
						+ "</label></td><td>"
						+ res[0].data[i].specialName
						+ "</td><td>"
						+ "<button type=\"button\" class=\"btn btn-default btn-xs\"onclick=\"del('"
						+ res[0].data[i].id
						+ "')\">"
						+ "删除"
						+ "</button>&nbsp;&nbsp;&nbsp;"
						+"<button type=\"button\" class=\"btn btn-default btn-xs\"onclick=\"addUpdateJurisdiction('"
						+ res[0].data[i].id
						+ "')\">"
						+ "编辑"
						+"</button>&nbsp;&nbsp;"
						+"</td></tr>";
				}
			}
			$("#findMemeber").append(str);
			/*var pagesize =1;
			for ( var i = 0; i < res.length; i++) {
				pagesize=res[i].curr;
			}
		 	 laypage({
				cont : document.getElementById('page2'), //容器。值支持id名、原生dom对象，jquery对象,
				pages : pagesize, //总页数
				skip : true, //是否开启跳页
				skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
				curr : curr || 1,
				last: res.pageSize,
				groups : 6,//连续显示分页数
				jump : function(obj, first) { //触发分页后的回调
					if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
						demo(obj.curr);
						var curr = obj.curr;
						curr = obj.curr;
					}
				}
			}); */ 
		});
	};
	//删除
	function del(deleteid) {
		if (confirm("是否确认删除！！")) {
			$.ajax({
				type : "post",
				url : "jurisdictionDelete.do",
				data : {
					"id" : deleteid
				},
				dataType : "json",
				success : function(data) {
					if(data[0].msg =="OK"){
						demo(1);
						layer.msg('删除成功');
					}else{
						alert("请求失败");
					}
				},
				error : function(data) {
					
				}
			});
		}
	}
	
</script>